package com.mfc.education.service.edu.service.impl;


import com.mfc.education.service.edu.entity.Subject;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.mfc.education.service.edu.entity.Subject;
import com.mfc.education.service.edu.entity.excel.ExcelSubjectData;
import com.mfc.education.service.edu.entity.vo.SubjectVo;
import com.mfc.education.service.edu.listener.ExcelSubjectDataListener;

import com.mfc.education.service.edu.mapper.SubjectMapper;
import com.mfc.education.service.edu.service.SubjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;



import java.io.InputStream;
import java.util.List;


/**
 * <p>
 * 课程科目 服务实现类
 * </p>
 *
 * @author Mfc
 * @since 2021-07-25
 */
@Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> implements SubjectService {



    @Override
    public void batchImport(InputStream inputStream) {
            EasyExcel.read(inputStream, ExcelSubjectData.class, new ExcelSubjectDataListener(getBaseMapper()))
                    .excelType(ExcelTypeEnum.XLS)
                    .sheet()
                    .doRead();
    }

    @Override
    public List<SubjectVo> nestedList() {

        return  baseMapper.selectTreeDataAll("0");
    }

}
